<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var singleNumber = function (nums) {
      const freq = new Map();
      for (const num of nums) {
        freq.set(num, (freq.get(num) || 0) + 1);
      }
      let ans = 0;
      for (const [num, occ] of freq.entries()) {
        if (occ === 1) {
          ans = num;
          break;
        }
      }
      return ans;
    };
    console.log(singleNumber(nums = [2, 2, 3, 2]))
  </script>
</body>

</html>